<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <title></title>
                <!--<meta name="viewport" content="width=device-width, initial-scale=1.0">-->
                <link href="__PUBLIC__/css/style.css" rel="stylesheet" type="text/css" />
                <link href="__PUBLIC__/css/select.css" rel="stylesheet" type="text/css" />
                <script type="text/javascript" src="__PUBLIC__/js/jquery-1.9.0.min.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/layer/layer.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/jquery.idTabs.min.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/select-ui.min.js"></script>
                <script type="text/javascript" src="__PUBLIC__/js/editor/kindeditor.js"></script>
                <script type="text/javascript">
                        KE.show({
                                id: 'content7',
                                cssPath: './index.css'
                        });

                        function queryErrorCodeByCode(errorCodeInput) {
                                //var errorCodeInput = $("#errorCodeInput").val();
                                if (errorCodeInput.length === 0) {
                                        layer.msg('请输入要查询的状态码', {shift: 6});
                                        return;
                                }
                                var url = "__APP__/Home/Errorcode/queryErrorCodeByCode";
                                var args = {"errorCode": errorCodeInput};
                                $.ajax({
                                        type: "GET",
                                        url: url,
                                        dataType: "json",
                                        data: args, //var args = {"time": new Date(), "n_id": n_id, "new_name": new_name};
                                        success: function(data) {
                                                if (data.error_code == null) {
                                                        layer.msg('没有查询到数据，请检查状态码是否输入正确', {shift: 6});
                                                } else {
                                                        if (data.error_code.code.length === 3) {
                                                                layer.alert("状态码：" + data.error_code.code + "<br/>级别：" + data.level + "<br/>详情：" + data.error_code.description);

                                                        } else {
                                                                layer.alert("状态码：" + data.error_code.code + "<br/>级别：" + data.level + "<br/>详情：" + data.error_code.description + "<br/>所属Api类：" + data.controller_class.class_name + "<br/>所属方法：" + data.controller_class_method.method_name);
                                                        }
                                                }
                                        }
                                });

                        }

                        function addErrorCode() {
                                var level_select = $("#level_select").find("option:selected").val();//_不填  public公共 | 服务级1  | 系统级2
                                //layer.alert(level_select);
                                if (level_select !== '1' && level_select !== '2') {
//                                        layer.alert("添加状态码时必须选择服务级或系统级");
                                        layer.msg('添加状态码时必须选择服务级或系统级', {shift: 6});
                                        return;
                                }
                                var controller_class_select = $("#controller_class_select").find("option:selected").val();//控制器ID
                                var controller_class_method_select = $("#controller_class_method_select").find("option:selected").val();//方法ID
//                                alert(controller_class_method_select);
//                                return;
                                if (controller_class_select.length === 0 || controller_class_method_select.length === 0) {
//                                        layer.alert("请填写完整");
                                        layer.msg('请填写完整', {shift: 6});
                                        return;
                                }
                                if (controller_class_method_select.length === 1) {
                                        controller_class_method_select = '0' + controller_class_method_select;
                                }
                                if (controller_class_select.length === 1) {
                                        controller_class_select = '0' + controller_class_select;
                                }
                                var code = level_select + controller_class_select + controller_class_method_select;
//                                alert(code);
                                var description = $("#errorNoteInput").val();
                                if (description.length === 0) {
//                                        layer.alert("状态说明不可为空");
                                        layer.msg('状态说明不可为空', {shift: 6});
                                        return;
                                }
//                                alert("controller_class_select" + controller_class_select);
//                                alert("controller_class_method_select:" + controller_class_method_select);
                                var args = {"code": code, "description": description};
                                var url = "__APP__/Home/Errorcode/addErrorCode";
                                $.ajax({
                                        type: "GET",
                                        url: url,
                                        dataType: "json",
                                        data: args, //var args = {"time": new Date(), "n_id": n_id, "new_name": new_name};
                                        success: function(msg) {
                                                //alert(msg.code);
                                                if (msg.info == '1') {
                                                        $("#queryErrorCodeButton").trigger("click");//重新执行查询，更新页面数据
                                                } else {
                                                        layer.msg('添加失败', {shift: 6});
                                                }
                                        }
                                });
                        }

                        function editErrorCode(errorcode, description) {
                                var url = "__APP__/Home/Errorcode/editErrorCode";
                                layer.use('extend/layer.ext.js', function() {
                                        layer.prompt({
                                                title: '输入新的状态码详情，并确认',
                                                formType: 2 //prompt风格，支持0-2
                                        }, function(description) {
                                                var args = {"code": errorcode, "description": description};
//                                                layer.msg('演示完毕！您的口令：' + description);
                                                $.ajax({
                                                        type: "GET",
                                                        url: url,
                                                        dataType: "text",
                                                        data: args, //var args = {"time": new Date(), "n_id": n_id, "new_name": new_name};
                                                        success: function(msg) {
                                                                if (msg == 1) {
                                                                        layer.msg('修改成功');
                                                                        $("#queryErrorCodeButton").trigger("click");//重新执行查询，更新页面数据
                                                                }
                                                        }
                                                });
                                        });

                                });
                        }

                        function deleteErrorCode(obj) {
                                var r = confirm("确认删除？");
                                var url = $(obj).attr("url");
                                if (r == false) {
                                        //alert("false");
                                        return false;
                                }
                                $.ajax({
                                        type: "GET",
                                        url: url,
                                        dataType: "text",
                                        data: {}, //var args = {"time": new Date(), "n_id": n_id, "new_name": new_name};
                                        success: function(msg) {
                                                if (msg > 0) {
//                                                        layer.alert("删除成功");
                                                        layer.msg('删除成功', {icon: 1});
                                                        //从table中删除当前行
                                                        $(obj).parent().parent().remove();
                                                }
                                        }
                                });
                                return false;
                        }

                        function queryErrorCode(obj) {
                                var level_select = $("#level_select").find("option:selected").val();//_不填  public公共 | 服务级1  | 系统级2
                                var controller_class_select = $("#controller_class_select").find("option:selected").val();//控制器ID
                                var controller_class_method_select = $("#controller_class_method_select").find("option:selected").val();//方法ID
                                if (level_select === "public") {

                                } else if (controller_class_select.length === 0 || controller_class_method_select.length === 0) {
//                                        layer.alert("请填写完整");
                                        layer.msg('请填写完整', {shift: 6});
                                        return;
                                }
                                if (controller_class_method_select.length === 1) {
                                        controller_class_method_select = "0" + controller_class_method_select;
                                }
                                if (controller_class_select.length === 1) {
                                        controller_class_select = "0" + controller_class_select;
                                }
                                var args = {"level": level_select, "controller_class": controller_class_select, "controller_class_method": controller_class_method_select}
                                // alert(level_select);
                                //var args = $(obj).parent().parent().children().eq(0).children().eq(0).children().eq(0).find("option:selected").val();
//                                var url = "__APP__/Home/Errorcode/queryErrorCode";
                                var url = "{:U('Errorcode/queryErrorCode')}";
                                $.ajax({
                                        type: "GET",
                                        url: url,
                                        dataType: "json",
                                        data: args, //var args = {"time": new Date(), "n_id": n_id, "new_name": new_name};
                                        success: function(msg) {
                                                //每次显示新数据前清除旧数据
                                                $("#errorCodeTable").find('tbody').empty();
                                                if (msg.length > 0) {
                                                        for (var i = 0; i < msg.length; i++) {
                                                                //alert(msg[i].code);
                                                                var firstTr = $("#errorCodeTable").find('tbody>tr:first');
                                                                var row = $("<tr></tr>");
                                                                var td1 = $("<td></td>");
                                                                var td2 = $("<td></td>");
                                                                var td3 = $("<td></td>");
                                                                var td4 = $("<td></td>");
                                                                td1.append($("<input name='' type='checkbox' value='' />"));
                                                                td2.append(msg[i].code);
                                                                td3.append(msg[i].description);
                                                                td4.append($("<a href='#' onclick='editErrorCode($(this).parent().parent().children().eq(1).text(),$(this).parent().parent().children().eq(2).text())' class='tablelink'>编辑</a>  <a href='#' onclick='queryErrorCodeByCode($(this).parent().parent().children().eq(1).text())' class='tablelink'>查看</a>  <a href='#' url='__APP__/Home/Errorcode/deleteErrorCode?code=" + msg[i].code + "' onclick='deleteErrorCode(this)' class='tablelink'> 删除</a>"));
                                                                row.append(td1);
                                                                row.append(td2);
                                                                row.append(td3);
                                                                row.append(td4);
                                                                $("#errorCodeTable").append(row);
                                                        }
                                                } else {
                                                        layer.msg('没有数据', {shift: 6});
                                                }
                                        }
                                }
                                );

                        }

                        $(function() {
//                                console.log("__APP__/Home/Api/menu")
                                $(parent.document).find("#leftFrame").attr("src", "{:U('Api/menu')}");
                                queryApiClass();
                                $(".select1").uedSelect({
                                        width: 345
                                });

                                $(".select2").uedSelect({
                                        width: 167
                                });

                                $(".select3").uedSelect({
                                        width: 140
                                });

                                $("#controller_class_select").change(function() {
                                        $("#controller_class_method_select").empty();
                                        var controller_class_select = $("#controller_class_select").find("option:selected").val();//控制器ID
                                        var url = "__APP__/Home/Api/queryMethodName";
                                        var args = {"controller_class": controller_class_select};
//                                        alert(1);
                                        $.ajax({
                                                type: "GET",
                                                url: url,
                                                dataType: "json",
                                                data: args,
                                                success: function(msg) {
                                                        $("#controller_class_method_select").append('<option value="" selected = "selected">请选择...</option>');
                                                        if (msg.length === 0) {
                                                                layer.msg('该控制器类没有方法', {shift: 6});
                                                                return;
                                                        }
                                                        for (var i = 0; i < msg.length; i++) {
//                                                        alert(msg[i].method_name);
                                                                $("#controller_class_method_select").append("<option value='" + msg[i].method_id + "'>" + msg[i].method_name + "</option>");
                                                        }
                                                }
                                        });
                                });
                                /*
                                 $("#addErrorCodeSubmit").click(function() {
                                 var codeInput = $("#codeInput").val();
                                 var descriptionInput = $("#descriptionInput").val();
                                 if (descriptionInput.length === 0 || codeInput.length === 0) {
                                 layer.alert("错误码和说明不可为空");
                                 return false;
                                 }
                                 var url = "__APP__/Home/Api/adderrorCode";
                                 $.ajax({
                                 type: "GET",
                                 url: url,
                                 dataType: "json",
                                 data: {"code": codeInput, "description": descriptionInput}, //var args = {"time": new Date(), "n_id": n_id, "new_name": new_name};
                                 success: function(msg) {
                                 if (msg.info === '0') {
                                 layer.alert("该错误码已经存在");
                                 } else {
                                 var arg = $("#apiClassId").find("option:selected").val();
                                 //                                                                alert(codeInput.substr(1,2));
                                 if ((codeInput.length === 3 && arg === "public") || codeInput.substr(1, 2) === arg) {
                                 //当前添加的错误码应该被添加到下面的table中
                                 var firstTr = $("#errorCodeTable").find('tbody>tr:first');
                                 var row = $("<tr></tr>");
                                 var td1 = $("<td></td>");
                                 var td2 = $("<td></td>");
                                 var td3 = $("<td></td>");
                                 var td4 = $("<td></td>");
                                 td1.append($("<input name='' type='checkbox' value='' />"));
                                 td2.append(codeInput);
                                 td3.append(descriptionInput);
                                 td4.append($("<a href='#' class='tablelink'>编辑</a>  <a href='#'  url='__APP__/Home/Api/deleteErrorCode?code=" + codeInput + "' onclick='deleteErrorCode(this)' class='tablelink'> 删除</a>"));
                                 row.append(td1);
                                 row.append(td2);
                                 row.append(td3);
                                 row.append(td4);
                                 $("#errorCodeTable").append(row);
                                 }
                                 }
                                 }
                                 });
                                 return false;
                                 });
                                 */
                        }
                        );</script>
        </head>
        <body>
                <div class="place">
                        <span>位置：</span>
                        <ul class="placeul">
                                <li><a href="#">首页</a></li>
                                <li><a href="#">Api首页</a></li>
                        </ul>
                </div>
                <div class="formbody">
                        <div id="usual1" class="usual"> 
                                <div class="itab">
                                        <ul> 
                                                <li><a href="#tab1" class="selected"> 状态码</a></li> 
                                                <li><a href="#tab2">API类和方法</a></li> 
                                                <!--
                                                <li><a href="#tab3">API类和方法</a></li> 
                                                <li><a href="#tab4">自定义1</a></li> 
                                                <li><a href="#tab5">自定义1</a></li> 
                                                <li><a href="#tab6">自定义1</a></li> 
                                                -->
                                        </ul>
                                </div> 
                                <div id="tab1" class="tabson">
                                        <div class="formtext">
                                                <!--Hi，<b>admin</b>，欢迎您使用错误码管理！-->
                                                <!--<br/>-->
                                                状态码格式说明:
                                                状态码由七位数字组成.
                                                例如：<b>1030406</b>公共状态码位3位<br/>
                                                <b>
                                                        ① 1表示为服务级错误。（2表示系统级错误）
                                                        ②03 表示当前接口类的ID为03
                                                        ③04 表示当前接口方法ID为04
                                                        ④06 表示当前的 状态码为当前接口方法的第6个错误码
                                                </b>
                                        </div>

                                        <!--------------------------------------->
                                        <!--
                                        <form action="#" method="post">
                                                <ul class="seachform" style="background-color:#E3E0D5">
                                                        <li>
                                                                <label>错误码</label>
                                                                <input name="code" id="codeInput" type="text" class="scinput" />
                                                        </li>
                                                        <li>
                                                                <label>说明</label>  
                                                                <input name="description" id="descriptionInput" type="text" class="scinput" style="width:518px;"/>
                                                        </li>
                                                        <li>
                                                                <label></label>
                                                                <input name="" type="button" id="addErrorCodeSubmit" class="scbtn" value="添加"/>
                                                        </li>
                                                </ul>
                                        </form>
                                        -->
                                        <!--
                                        <ul class="formtext">
                                                <li>
                                                        <div class="vocation">
                                                                <select class="select1" name="apiClassId" id="apiClassId">
                                                                        <option value="public">公共错误码</option>
                                                                        <option value="01">UserApi</option>
                                                                </select>
                                                        </div>
                                                </li>
                                                <li>
                                                        <input name="" type="button" id="queryErrorCodeButton" class="btn" onclick="queryErrorCode(this)" value="查询错误码"/>
                                                        <label>示例：</label>
                                                </li>
                                        </ul>
                                        -->
                                        <ul class="seachform">
                                                <!--<li><label>综合查询</label><input name="" type="text" class="scinput" /></li>-->
                                                <li><label>级别</label>  
                                                        <div class="vocation">
                                                                <select class="select3" name="level_select" id="level_select">
                                                                        <option value="_">不填</option>
                                                                        <option value="public">公共</option>
                                                                        <option value="1">服务级</option>
                                                                        <option value="2">系统级</option>
                                                                </select>
                                                        </div>
                                                </li>

                                                <li><label>API</label>  
                                                        <div class="vocation">
                                                                <select class="select3" name="controller_class_select" id="controller_class_select">
                                                                        <option value="" selected = "selected">请选择...</option>
                                                                        <!--<option value="01">UserApi</option>-->
                                                                </select>
                                                        </div>
                                                </li>

                                                <li><label>方法</label>  
                                                        <div class="vocation">
                                                                <select class="select3" name="controller_class_method_select" id="controller_class_method_select">
                                                                        <option value="" selected = "selected">请选择...</option>
                                                                </select>
                                                        </div>
                                                </li>
                                                <li>
                                                        <label>&nbsp;</label>
                                                        <input name="" type="button" id="queryErrorCodeButton" onclick="queryErrorCode(this)" class="scbtn" value="查询"/>
                                                </li>
                                                <li>
                                                        <label><input name="errorNoteInput" id="errorNoteInput" type="text" class="scinput" placeholder="输入新的状态说明并添加" /></label>
                                                        <input name="" type="button" onclick="addErrorCode()" class="scbtn" value="添加状态码"/>
                                                </li>
                                                <li>
                                                        <label>
                                                                <input name="errorCodeInput" id="errorCodeInput" type="text" class="scinput" placeholder="输入完整的状态码查询" />
                                                        </label>
                                                        <input name="" type="button" onclick="queryErrorCodeByCode($(this).parent().children().eq(0).children().eq(0).val())" class="scbtn" value="查询状态码"/>
                                                </li>
                                        </ul>
                                        <table class="tablelist"  id="errorCodeTable">
                                                <thead>
                                                        <tr>
                                                                <th><input name="" type="checkbox" value="" checked="checked"/></th>
                                                                <th>错误码<i class="sort"><img src="__PUBLIC__/images/px.gif" /></i></th>
                                                                <th>说明</th>
                                                                <th>操作</th>
                                                        </tr>
                                                </thead>
                                                <tbody id="errorCodeTableBody">
                                                        <!--
                                                        <tr>
                                                                <td><input name="" type="checkbox" value="" /></td>
                                                                <td>1010101</td>
                                                                <td>用户名或密码不可以为空</td>
                                                                <td>
                                                                        <a href="#" class="tablelink">编辑</a>     
                                                                        <a href="#" class="tablelink"> 删除</a>
                                                                </td>
                                                        </tr> 
                                                        -->
                                                </tbody>
                                        </table>
                                </div> 
                                <div id="tab2" class="tabson">
                                        <ul class="seachform">
                                                <li>
                                                        <label>API类</label>
                                                        <!--<input name="" type="text" class="scinput" />-->
                                                        <div class="vocation">
                                                                <select class="select3" id="class_idSelect" onchange="queryMethod()">
                                                                        <option value="" selected="selected">请选择...</option>
                                                                        <!--<option value="1">UserApi</option>--><!--value对应class_id,方法表中做外键关联-->
                                                                </select>
                                                        </div>
                                                </li>
                                                <li>
                                                        <label>
                                                                <input name="" id="methodNameInput" type="text" class="scinput" placeholder="添加方法到选中的API类"/>
                                                                <input name="" id="methodDescriptionNameInput" type="text" class="scinput" placeholder="方法说明"/>
                                                        </label>  
                                                        <input name="" type="button" onclick="addMethodToApiClass()" class="scbtn" value="添加方法"/>
                                                        <script type="text/javascript">
                                                                function deleteApiClass(obj) {
//                                                                        alert("请勿删除，若要删除请修改api_main.html    line：455");
//                                                                        return;
                                                                        var r = confirm("确认删除？");
                                                                        if (r == false) {
                                                                                return false;
                                                                        }
                                                                        var url = $(obj).attr("url");
                                                                        $.ajax({
                                                                                type: 'get',
                                                                                url: url,
                                                                                //data: {"controller_class": class_idSelect},
                                                                                dataType: 'json',
                                                                                success: function(data) {
//                                                                                        alert(data.info);
                                                                                        if (data.info > 0) {
//                                                                                                layer.alert("删除成功");
                                                                                                layer.msg('删除成功', {icon: 1});
                                                                                                $(obj).parent().parent().remove();
                                                                                        } else {
                                                                                                layer.msg('删除失败', {shift: 6});
                                                                                        }
                                                                                }
                                                                        });
                                                                }

                                                                function queryMethod() {
                                                                        var class_idSelect = $("#class_idSelect").find("option:selected").val();
                                                                        if (class_idSelect.length === 0) {
                                                                                //选中的是  “请选择”
                                                                                return;
                                                                        }
                                                                        $.ajax({
                                                                                type: 'get',
                                                                                url: '__APP__/Home/Api/queryMethodName',
                                                                                data: {"controller_class": class_idSelect},
                                                                                dataType: 'json',
                                                                                success: function(data) {
                                                                                        $("#ApiClassTable").find('tbody').empty();
                                                                                        if (data.length === 0) {
                                                                                                layer.msg('没有数据', {shift: 6});
                                                                                                return;
                                                                                        }
                                                                                        for (var i = 0; i < data.length; i++) {
                                                                                                var firstTr = $("#ApiClassTable").find('tbody>tr:first');
                                                                                                var row = $("<tr></tr>");
                                                                                                var td1 = $("<td></td>");
                                                                                                var td2 = $("<td></td>");
                                                                                                var td3 = $("<td></td>");
                                                                                                var td4 = $("<td></td>");
                                                                                                var td5 = $("<td></td>");
                                                                                                td1.append($("<input name='' type='checkbox' value='' />"));
                                                                                                td2.append(data[i].method_id);
                                                                                                td3.append(data[i].method_name);
                                                                                                td4.append(data[i].note);
                                                                                                td5.append($("<a href='#' class='tablelink'>查看</a>  <a href='#' onclick='deleteApiClass(this)' url='__APP__/Home/Api/deleteApiClass?type=method&method_id=" + data[i].method_id + "' class='tablelink'> 删除</a>"));
                                                                                                row.append(td1);
                                                                                                row.append(td2);
                                                                                                row.append(td3);
                                                                                                row.append(td4);
                                                                                                row.append(td5);
                                                                                                $("#ApiClassTable").append(row);
                                                                                        }
                                                                                }
                                                                        });
                                                                }

                                                                function addMethodToApiClass() {
                                                                        var class_idSelect = $("#class_idSelect").find("option:selected").val();//类ID
                                                                        var methodNameInput = $("#methodNameInput").val();
                                                                        var methodDescriptionNameInput = $("#methodDescriptionNameInput").val();
                                                                        if (class_idSelect.length === 0) {
//                                                                                layer.alert("请选择API类");
                                                                                layer.msg('请选择API类', {shift: 6});
                                                                                return;
                                                                        }
                                                                        if (methodNameInput.length === 0) {
//                                                                                layer.alert("请填写完整");
                                                                                layer.msg('请填写完整', {shift: 6});
                                                                                return;
                                                                        }
                                                                        $.ajax({
                                                                                type: 'get',
                                                                                url: '__APP__/Home/Api/addMethodToApiClass',
                                                                                data: {"class_id": class_idSelect, "method_name": methodNameInput, "note": methodDescriptionNameInput},
                                                                                dataType: 'json',
                                                                                success: function(data) {
                                                                                        var firstTr = $("#ApiClassTable").find('tbody>tr:first');
                                                                                        var row = $("<tr></tr>");
                                                                                        var td1 = $("<td></td>");
                                                                                        var td2 = $("<td></td>");
                                                                                        var td3 = $("<td></td>");
                                                                                        var td4 = $("<td></td>");
                                                                                        var td5 = $("<td></td>");
                                                                                        td1.append($("<input name='' type='checkbox' value='' />"));
                                                                                        td2.append(data.method_id);
                                                                                        td3.append(data.method_name);
                                                                                        td4.append(data.note);
                                                                                        td5.append($("<a href='#' class='tablelink'>查看</a>  <a href='#'  onclick='deleteApiClass(this)' url='__APP__/Home/Api/deleteApiClass?type=method&method_id=" + data.method_id + "' class='tablelink'> 删除</a>"));
                                                                                        row.append(td1);
                                                                                        row.append(td2);
                                                                                        row.append(td3);
                                                                                        row.append(td4);
                                                                                        row.append(td5);
                                                                                        $("#ApiClassTable").append(row);
                                                                                        layer.msg('添加成功', {icon: 1});
                                                                                }
                                                                        });
                                                                }
                                                        </script>
                                                </li>


                                                <li>
                                                        <form id="addApiClassForm" action="">
                                                                <label>
                                                                        <input name="ApiClassInput" type="text" id="ApiClassInput" class="scinput" placeholder="添加API类"/>
                                                                        <input name="ApiClassNoteInput" type="text" id="ApiClassNoteInput" class="scinput" placeholder="添加API类说明"/>
                                                                </label>
                                                                <input name="" type="button" onclick="addApiClass()" class="scbtn" value="添加Api类"/>
                                                                <input name="" type="button" onclick="queryApiClass()" class="scbtn" value="查询Api类"/>

                                                        </form>
                                                </li>
                                        </ul>
                                        <script type="text/javascript">
                                                function queryApiClass() {
                                                        $.ajax({
                                                                type: 'get',
                                                                url: '__APP__/Home/Api/queryApiClass',
                                                                //data: formParam,
                                                                dataType: 'json',
                                                                success: function(data) {
//                                                                     给API类的下拉框添加数据
                                                                        $("#class_idSelect").empty();
                                                                        $("#class_idSelect").append('<option value="" selected = "selected">请选择...</option>');

                                                                        $("#controller_class_select").empty();
                                                                        $("#controller_class_select").append('<option value="" selected = "selected">请选择...</option>');

                                                                        $("#ApiClassTable").find('tbody').empty();
                                                                        if (data.length === 0) {
                                                                                layer.msg('没有数据', {shift: 6});
                                                                                return;
                                                                        }
                                                                        layer.msg('共' + data.length + '个API类', {icon: 1});
                                                                        for (var i = 0; i < data.length; i++) {
                                                                                $("#class_idSelect").append("<option value='" + data[i].class_id + "'>" + data[i].class_name + "</option>");
                                                                                $("#controller_class_select").append("<option value='" + data[i].class_id + "'>" + data[i].class_name + "</option>");
                                                                                var firstTr = $("#ApiClassTable").find('tbody>tr:first');
                                                                                var row = $("<tr></tr>");
                                                                                var td1 = $("<td></td>");
                                                                                var td2 = $("<td></td>");
                                                                                var td3 = $("<td></td>");
                                                                                var td4 = $("<td></td>");
                                                                                var td5 = $("<td></td>");
                                                                                td1.append($("<input name='' type='checkbox' value='' />"));
                                                                                td2.append(data[i].class_id);
                                                                                td3.append(data[i].class_name);
                                                                                td4.append(data[i].note);
                                                                                td5.append($("<a href='#' class='tablelink'>查看</a>  <a href='#'  onclick='deleteApiClass(this)' url='__APP__/Home/Api/deleteApiClass?type=class&class_id=" + data[i].class_id + "' class='tablelink'> 删除</a>"));
                                                                                row.append(td1);
                                                                                row.append(td2);
                                                                                row.append(td3);
                                                                                row.append(td4);
                                                                                row.append(td5);
                                                                                $("#ApiClassTable").append(row);
                                                                        }
                                                                }
                                                        });
                                                }

                                                function addApiClass() {
                                                        var ApiClassInput = $("#ApiClassInput").val();
                                                        var ApiClassNoteInput = $("#ApiClassNoteInput").val();
                                                        if (ApiClassInput.length === 0 || ApiClassNoteInput.length === 0) {
//                                                                layer.alert("请填写完整");
                                                                layer.msg('请填写完整', {shift: 6});
                                                                return;
                                                        }
                                                        var formParam = $("#addApiClassForm").serialize();//序列化表格内容为字符串    
                                                        $.ajax({
                                                                type: 'get',
                                                                url: '__APP__/Home/Api/addApiClass',
                                                                data: formParam,
                                                                dataType: 'json',
                                                                success: function(data) {
                                                                        if (data.info === "1") {
                                                                                queryApiClass();
                                                                                /*
                                                                                 $("#ApiClassTable").find('tbody').empty();
                                                                                 var firstTr = $("#ApiClassTable").find('tbody>tr:first');
                                                                                 var row = $("<tr></tr>");
                                                                                 var td1 = $("<td></td>");
                                                                                 var td2 = $("<td></td>");
                                                                                 var td3 = $("<td></td>");
                                                                                 var td4 = $("<td></td>");
                                                                                 var td5 = $("<td></td>");
                                                                                 td1.append($("<input name='' type='checkbox' value='' />"));
                                                                                 td2.append(data.class_id);
                                                                                 td3.append(data.class_name);
                                                                                 td4.append(data.note);
                                                                                 td5.append($("<a href='#' class='tablelink'>查看</a>  <a href='#' url='__APP__/Home/Api/deleteApiClass?type=class&class_id=" + data.class_id + " class='tablelink'> 删除</a>"));
                                                                                 row.append(td1);
                                                                                 row.append(td2);
                                                                                 row.append(td3);
                                                                                 row.append(td4);
                                                                                 row.append(td5);
                                                                                 $("#ApiClassTable").append(row);
                                                                                 */
                                                                        } else {
//                                                                                layer.alert("添加失败");
                                                                                layer.msg('添加失败', {shift: 6});
                                                                        }
                                                                }
                                                        });
                                                }
                                        </script>


                                        <table class="tablelist" id="ApiClassTable">
                                                <thead>
                                                        <tr>
                                                                <th>
                                                                        <input name="" type="checkbox" value="" checked="checked"/>
                                                                </th>
                                                                <th>ID<i class="sort"><img src="__PUBLIC__/images/px.gif" /></i></th>
                                                                <th>Name</th>
                                                                <th>Description</th>
                                                                <th>操作</th>
                                                        </tr>
                                                </thead>
                                                <tbody>
                                                        <!--
                                                        <tr>
                                                                <td><input name="" type="checkbox" value="" /></td>
                                                                <td>1</td>
                                                                <td>UserApi</td>
                                                                <td>用户接口类</td>
                                                                <td><a href="#" class="tablelink">查看</a>     <a href="#" class="tablelink"> 删除</a></td>
                                                        </tr> 
                                                        -->
                                                </tbody>
                                        </table>
                                </div>  
                                <!--
                                <div id="tab3" class="tabson">
                                </div>
                                <div id="tab4" class="tabson">
                                </div>
                                <div id="tab5" class="tabson">
                                </div>
                                <div id="tab6" class="tabson">
                                </div>
                                -->
                        </div> 

                        <script type="text/javascript">
                                $("#usual1 ul").idTabs();
                        </script>

                        <script type="text/javascript">
                                $('.tablelist tbody tr:odd').addClass('odd');
                        </script>
                </div>

        </body>
</html>